//
//  PublicSetUserInfoApi.m
//  3DPrint
//
//  Created by Fidetro on 2017/1/10.
//  Copyright © 2017年 Fidetro. All rights reserved.
//

#import "PublicSetUserInfoApi.h"

@implementation PublicSetUserInfoApi
{
    NSDictionary *_dic;
}

-(instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        _dic = dic;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/new/user/set_user_info";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (AFConstructingBlock)constructingBodyBlock
{
    if ([NSData dataWithContentsOfFile:_dic[@"image"]] == nil) {
        return nil;
    }
    return ^(id<AFMultipartFormData> formData) {
        NSError *error;
        
        [formData appendPartWithFileURL:[NSURL fileURLWithPath:_dic[@"image"]] name:@"image" error:&error];
        
    };
}




- (id)requestArgument {
    
    
    
    NSMutableDictionary * mdic = [NSMutableDictionary getPubdic];
    
    if (_dic[@"nickname"] != nil){
        [mdic setObject:_dic[@"nickname"] forKey:@"nickname"];
    }
    if (_dic[@"sex"]!= nil) {
        [mdic setObject:_dic[@"sex"] forKey:@"sex"];
    }
    if (_dic[@"birth"]!= nil) {
        [mdic setObject:_dic[@"birth"] forKey:@"birth"];
    }
    if (_dic[@"height"]!= nil) {
        [mdic setObject:_dic[@"height"] forKey:@"height"];
    }
    if (_dic[@"weight"]!= nil) {
        [mdic setObject:_dic[@"weight"] forKey:@"weight"];
    }
    
    NSString * sign = [NSString getSign:mdic];
    [mdic setObject:sign forKey:@"sign"];
    
    return mdic;
}




@end
